package com.chaopei.thread;

/**
 * @Author Corday 天涯
 * @Date 2022/3/14 15:03
 */
public class MyShowThread  extends Thread {
    private  MyCalcThread myCalcThread;
    public  MyShowThread(MyCalcThread myCalcThread){
        this.myCalcThread = myCalcThread;
    }
     //执行的代码
    @Override
    public void run() {
        for(int i=0;i<=50;i++){
        int sum= myCalcThread.getSum();
            System.out.println("和值："+sum);
            if(myCalcThread.getFlag()>=50){
                break;
            }
            try {
                Thread.sleep(120);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }//for
    }
}
